package com.parking.service.impl;

import com.parking.bean.ParkAdmin;
import com.parking.dao.ParkAdminDao;
import com.parking.dao.impl.ParkAdminDaoImpl;
import com.parking.service.ParkAdminService;

import java.util.List;

public class ParkAdminServiceImpl implements ParkAdminService {
    private ParkAdminDao parkAdminDao =new ParkAdminDaoImpl();
    @Override
    public List<ParkAdmin> list() {
        return parkAdminDao.list();
    }

    @Override
    public List<ParkAdmin> search(String key, String value) {
        if(value.equals("")) return this.parkAdminDao.list();
        return this.parkAdminDao.search(key,value);
    }

    @Override
    public void save(ParkAdmin parkAdmin) {
        Integer save=this.parkAdminDao.save(parkAdmin);
        if (save!=1) throw new RuntimeException("宿管信息添加失败");
    }
    @Override
    public void update(ParkAdmin parkAdmin) {
        Integer update=this.parkAdminDao.update(parkAdmin);
        if (update!=1) throw new RuntimeException("宿管信息更新失败");
    }

    @Override
    public void delete(String id) {
        Integer delete=this.parkAdminDao.delete(id);
        if (delete!=1) throw new RuntimeException("宿管信息更新失败");
    }
}
